function Food(el){
    //保存地图大茴香
    this.el = el
    //保存食物相关属性
    this.width = 20
    this.height = 20

    this.foodObj = null

    this.foodLeft = 0
    this.foodTop = 0

}
Food.prototype.create = function(){
    //创建div标签对象
    let divObj = document.createElement('div')
    //设置标签对象样式
    divObj.style.width = this.width + 'px'
    divObj.style.height = this.height + 'px'
    divObj.style.background = 'green'
    divObj.style.position = 'absolute'
    //将div标签对象显示在地图上
    this.el.appendChild(divObj)

    //单独保存食物对象
    this.foodObj = divObj
    this.move()
}
//
Food.prototype.move = function(){
    //地图放置食物的最大个数
    let foodXmaxNum = this.el.clientWidth / this.width  //40，但不能超过40
    let foodYmaxNum = this.el.clientHeight / this.height  //20，但不能超过20
    //随机显示食物
    this.foodLeft = Math.floor(Math.random()*(foodXmaxNum-1-0+1)+0) * this.width
    this.foodTop = Math.floor(Math.random()*(foodYmaxNum-1-0+1)+0) * this.height
    console.log(this.foodLeft,this.foodTop)
    this.foodObj.style.left = this.foodLeft + 'px'
    this.foodObj.style.top = this.foodTop + 'px'
}